// 业务类型
export const BUSINESS_TYPE = {
  SHOP_TYPE: 1,
  BOOK_TYPE: 2,
  MEAL_TYPE: 3,
  RESERVATION_TYPE: 4,
  PUBORDER_TYPE:5
}
export const BUSINESS_TYPE_TEXT = {
  [BUSINESS_TYPE.SHOP_TYPE]: '商城',
  [BUSINESS_TYPE.BOOK_TYPE]: '预定',
  [BUSINESS_TYPE.MEAL_TYPE]: '点餐',
  [BUSINESS_TYPE.RESERVATION_TYPE]: '预约',
  [BUSINESS_TYPE.PUBORDER_TYPE]: '公域',
}

export const business_type_options = [
  {
    label: BUSINESS_TYPE_TEXT[BUSINESS_TYPE.SHOP_TYPE],
    value: BUSINESS_TYPE.SHOP_TYPE,
    routerPath: '/wxaMallModule/orderManage'
  },
  {
    label: BUSINESS_TYPE_TEXT[BUSINESS_TYPE.BOOK_TYPE],
    value: BUSINESS_TYPE.BOOK_TYPE,
    routerPath: '/bookingModule/orderRecord'
  },
  {
    label: BUSINESS_TYPE_TEXT[BUSINESS_TYPE.MEAL_TYPE],
    value: BUSINESS_TYPE.MEAL_TYPE,
    routerPath: '/wcyModule/orderRecord'
  },
  {
    label: BUSINESS_TYPE_TEXT[BUSINESS_TYPE.RESERVATION_TYPE],
    value: BUSINESS_TYPE.RESERVATION_TYPE,
    routerPath: '/wxaReservationModule/orderManage'
  },
  {
    label: BUSINESS_TYPE_TEXT[BUSINESS_TYPE.PUBORDER_TYPE],
    value: BUSINESS_TYPE.PUBORDER_TYPE,
    routerPath: '/OrderCenter/TradeOrder'
  }
]

// 订单类型
/*
 * 商城订单: 1:物流,2:外卖,3:自提 ，
 * 预定订单: 0:全日房间 1:钟点房 2:ktv，
 *  餐饮订单: 1:堂食 2:打包
 * */

export const ORDER_TYPE_FOR_SHOP = {
  EXPRESS: 1,
  TAKE_OUE: 2,
  SELF_DELIVERY: 3
}
export const ORDER_TYPE_FOR_BOOK = {
  FULL_DAY_ROOM: 0,
  HORY_ROOM: 1,
  KTV_ROOM: 2
}
export const ORDER_TYPE_FOR_MEAL = {
  HALL_FOOD: 1,
  PACKING: 2
}
export const ORDER_TYPE_FOR_RESERVATION = {
  RESERVATION: 1
}
export const ORDER_TYPE_FOR_PUBORDER = {
  HALL_FOOD: 4,
  PACKING:5,
  STORECONSUMPTION:6,
  TAKE_OUE:7,
  SELF_DELIVERY:8
}

export const orderTypeOptions = [
  {
    label: '物流',
    value: ORDER_TYPE_FOR_SHOP.EXPRESS,
    type: BUSINESS_TYPE.SHOP_TYPE
  },
  {
    label: '外卖',
    value: ORDER_TYPE_FOR_SHOP.TAKE_OUE,
    type: BUSINESS_TYPE.SHOP_TYPE
  },
  {
    label: '自提',
    value: ORDER_TYPE_FOR_SHOP.SELF_DELIVERY,
    type: BUSINESS_TYPE.SHOP_TYPE
  },
  {
    label: '全日房',
    value: ORDER_TYPE_FOR_BOOK.FULL_DAY_ROOM,
    type: BUSINESS_TYPE.BOOK_TYPE
  },
  {
    label: '钟点房',
    value: ORDER_TYPE_FOR_BOOK.HORY_ROOM,
    type: BUSINESS_TYPE.BOOK_TYPE
  },
  {
    label: 'KTV',
    value: ORDER_TYPE_FOR_BOOK.KTV_ROOM,
    type: BUSINESS_TYPE.BOOK_TYPE
  },
  {
    label: '堂食',
    value: ORDER_TYPE_FOR_MEAL.HALL_FOOD,
    type: BUSINESS_TYPE.MEAL_TYPE
  },
  {
    label: '打包',
    value: ORDER_TYPE_FOR_MEAL.PACKING,
    type: BUSINESS_TYPE.MEAL_TYPE
  },
  {
    label: '预约',
    value: ORDER_TYPE_FOR_RESERVATION.RESERVATION,
    type: BUSINESS_TYPE.RESERVATION_TYPE
  },
  {
    label: '堂食',
    value: ORDER_TYPE_FOR_PUBORDER.HALL_FOOD,
    type: BUSINESS_TYPE.PUBORDER_TYPE
  },
  {
    label: '打包',
    value: ORDER_TYPE_FOR_PUBORDER.PACKING,
    type: BUSINESS_TYPE.PUBORDER_TYPE
  },
  {
    label: '自提',
    value: ORDER_TYPE_FOR_PUBORDER.SELF_DELIVERY,
    type: BUSINESS_TYPE.PUBORDER_TYPE
  },
  {
    label: '到店消费',
    value: ORDER_TYPE_FOR_PUBORDER.STORECONSUMPTION,
    type: BUSINESS_TYPE.PUBORDER_TYPE
  },
  {
    label: '外卖配送',
    value: ORDER_TYPE_FOR_PUBORDER.TAKE_OUE,
    type: BUSINESS_TYPE.PUBORDER_TYPE
  },
]

/*
 * 订单规则
 * 推送规则：<br/>
 * 商城
 * 外卖	1：待支付	2：已支付/待配送	3：配送中		4：买家已确认	5：买家已取消<br/>
 * 自提	1：待支付	2：已支付/待自提	3：买家已自提 	4：买家已取消<br/>
 * 物流	1：待支付	2：已支付/待发货	3：已发货 		4：买家已确认	5：买家已取消<br/><br/>
 * 预定
 * 钟点房	1：待支付	2：已支付/待确认	3：已确认/待消费	4：已到店消费	5：买家已取消<br/>
 * 全日房	1：待支付	2：已支付/待确认	3：已确认/待游费	4：已到店消费	5：买家已取消<br/>
 * ktv		1：待支付	2：已支付/待确认	3：已确认待消费		4：已到店消费	5：买家已取消<br/><br/>
 * 餐饮
 * 堂食	1：待支付	2：已完成	3：买家已取消<br/>
 * 打包	1：待支付	2：已完成	3：买家已取消
 * 预约
 * 预约	1：待支付 2：待服务 3：已完成: 4：买家已取消
 * */
export const orderStateOptions = [
  // 物流状态
  {
    label: '待支付',
    value: 1,
    shop_type: BUSINESS_TYPE.SHOP_TYPE,
    order_type: ORDER_TYPE_FOR_SHOP.EXPRESS
  },
  {
    label: '已支付/待发货',
    value: 2,
    shop_type: BUSINESS_TYPE.SHOP_TYPE,
    order_type: ORDER_TYPE_FOR_SHOP.EXPRESS
  },
  {
    label: '已发货',
    value: 3,
    shop_type: BUSINESS_TYPE.SHOP_TYPE,
    order_type: ORDER_TYPE_FOR_SHOP.EXPRESS
  },
  {
    label: '买家已确认',
    value: 4,
    shop_type: BUSINESS_TYPE.SHOP_TYPE,
    order_type: ORDER_TYPE_FOR_SHOP.EXPRESS
  },
  {
    label: '买家已取消',
    value: 5,
    shop_type: BUSINESS_TYPE.SHOP_TYPE,
    order_type: ORDER_TYPE_FOR_SHOP.EXPRESS
  },
  // 外卖
  {
    label: '待支付',
    value: 1,
    shop_type: BUSINESS_TYPE.SHOP_TYPE,
    order_type: ORDER_TYPE_FOR_SHOP.TAKE_OUE
  },
  {
    label: '已支付/待配送',
    value: 2,
    shop_type: BUSINESS_TYPE.SHOP_TYPE,
    order_type: ORDER_TYPE_FOR_SHOP.TAKE_OUE
  },
  {
    label: '配送中',
    value: 3,
    shop_type: BUSINESS_TYPE.SHOP_TYPE,
    order_type: ORDER_TYPE_FOR_SHOP.TAKE_OUE
  },
  {
    label: '买家已确认',
    value: 4,
    shop_type: BUSINESS_TYPE.SHOP_TYPE,
    order_type: ORDER_TYPE_FOR_SHOP.TAKE_OUE
  },
  {
    label: '买家已取消',
    value: 5,
    shop_type: BUSINESS_TYPE.SHOP_TYPE,
    order_type: ORDER_TYPE_FOR_SHOP.TAKE_OUE
  },
  // 自提
  {
    label: '待支付',
    value: 1,
    shop_type: BUSINESS_TYPE.SHOP_TYPE,
    order_type: ORDER_TYPE_FOR_SHOP.SELF_DELIVERY
  },
  {
    label: '已支付/待自提',
    value: 2,
    shop_type: BUSINESS_TYPE.SHOP_TYPE,
    order_type: ORDER_TYPE_FOR_SHOP.SELF_DELIVERY
  },
  {
    label: '买家已自提',
    value: 4,
    shop_type: BUSINESS_TYPE.SHOP_TYPE,
    order_type: ORDER_TYPE_FOR_SHOP.SELF_DELIVERY
  },
  {
    label: '买家已取消',
    value: 5,
    shop_type: BUSINESS_TYPE.SHOP_TYPE,
    order_type: ORDER_TYPE_FOR_SHOP.SELF_DELIVERY
  },
  // 全日房
  {
    label: '待支付',
    value: 1,
    shop_type: BUSINESS_TYPE.BOOK_TYPE,
    order_type: ORDER_TYPE_FOR_BOOK.FULL_DAY_ROOM
  },
  {
    label: '已支付/待确认',
    value: 2,
    shop_type: BUSINESS_TYPE.BOOK_TYPE,
    order_type: ORDER_TYPE_FOR_BOOK.FULL_DAY_ROOM
  },
  {
    label: '已确认/待消费',
    value: 3,
    shop_type: BUSINESS_TYPE.BOOK_TYPE,
    order_type: ORDER_TYPE_FOR_BOOK.FULL_DAY_ROOM
  },
  {
    label: '已到店消费',
    value: 4,
    shop_type: BUSINESS_TYPE.BOOK_TYPE,
    order_type: ORDER_TYPE_FOR_BOOK.FULL_DAY_ROOM
  },
  {
    label: '买家已取消',
    value: 5,
    shop_type: BUSINESS_TYPE.BOOK_TYPE,
    order_type: ORDER_TYPE_FOR_BOOK.FULL_DAY_ROOM
  },
  // 钟点房
  {
    label: '待支付',
    value: 1,
    shop_type: BUSINESS_TYPE.BOOK_TYPE,
    order_type: ORDER_TYPE_FOR_BOOK.HORY_ROOM
  },
  {
    label: '已支付/待确认',
    value: 2,
    shop_type: BUSINESS_TYPE.BOOK_TYPE,
    order_type: ORDER_TYPE_FOR_BOOK.HORY_ROOM
  },
  {
    label: '已确认/待消费',
    value: 3,
    shop_type: BUSINESS_TYPE.BOOK_TYPE,
    order_type: ORDER_TYPE_FOR_BOOK.HORY_ROOM
  },
  {
    label: '已到店消费',
    value: 4,
    shop_type: BUSINESS_TYPE.BOOK_TYPE,
    order_type: ORDER_TYPE_FOR_BOOK.HORY_ROOM
  },
  {
    label: '买家已取消',
    value: 5,
    shop_type: BUSINESS_TYPE.BOOK_TYPE,
    order_type: ORDER_TYPE_FOR_BOOK.HORY_ROOM
  },
  // ktv
  {
    label: '待支付',
    value: 1,
    shop_type: BUSINESS_TYPE.BOOK_TYPE,
    order_type: ORDER_TYPE_FOR_BOOK.KTV_ROOM
  },
  {
    label: '已支付/待确认',
    value: 2,
    shop_type: BUSINESS_TYPE.BOOK_TYPE,
    order_type: ORDER_TYPE_FOR_BOOK.KTV_ROOM
  },
  {
    label: '已确认/待消费',
    value: 3,
    shop_type: BUSINESS_TYPE.BOOK_TYPE,
    order_type: ORDER_TYPE_FOR_BOOK.KTV_ROOM
  },
  {
    label: '已到店消费',
    value: 4,
    shop_type: BUSINESS_TYPE.BOOK_TYPE,
    order_type: ORDER_TYPE_FOR_BOOK.KTV_ROOM
  },
  {
    label: '买家已取消',
    value: 5,
    shop_type: BUSINESS_TYPE.BOOK_TYPE,
    order_type: ORDER_TYPE_FOR_BOOK.KTV_ROOM
  },
  // 堂食
  {
    label: '待支付',
    value: 1,
    shop_type: BUSINESS_TYPE.MEAL_TYPE,
    order_type: ORDER_TYPE_FOR_MEAL.HALL_FOOD
  },
  {
    label: '已完成',
    value: 2,
    shop_type: BUSINESS_TYPE.MEAL_TYPE,
    order_type: ORDER_TYPE_FOR_MEAL.HALL_FOOD
  },
  {
    label: '买家已取消',
    value: 3,
    shop_type: BUSINESS_TYPE.MEAL_TYPE,
    order_type: ORDER_TYPE_FOR_MEAL.HALL_FOOD
  },
  // 自提
  {
    label: '待支付',
    value: 1,
    shop_type: BUSINESS_TYPE.MEAL_TYPE,
    order_type: ORDER_TYPE_FOR_MEAL.PACKING
  },
  {
    label: '已完成',
    value: 2,
    shop_type: BUSINESS_TYPE.MEAL_TYPE,
    order_type: ORDER_TYPE_FOR_MEAL.PACKING
  },
  {
    label: '买家已取消',
    value: 3,
    shop_type: BUSINESS_TYPE.MEAL_TYPE,
    order_type: ORDER_TYPE_FOR_MEAL.PACKING
  },
  // 预约
  {
    label: '待支付',
    value: 1,
    shop_type: BUSINESS_TYPE.RESERVATION_TYPE,
    order_type: ORDER_TYPE_FOR_RESERVATION.RESERVATION
  },
  {
    label: '待服务',
    value: 2,
    shop_type: BUSINESS_TYPE.RESERVATION_TYPE,
    order_type: ORDER_TYPE_FOR_RESERVATION.RESERVATION
  },
  {
    label: '已完成',
    value: 3,
    shop_type: BUSINESS_TYPE.RESERVATION_TYPE,
    order_type: ORDER_TYPE_FOR_RESERVATION.RESERVATION
  },
  {
    label: '买家已取消',
    value: 4,
    shop_type: BUSINESS_TYPE.RESERVATION_TYPE,
    order_type: ORDER_TYPE_FOR_RESERVATION.RESERVATION
  },

   // 公域订单-堂食
   {
    label: '待支付',
    value: 1,
    shop_type: BUSINESS_TYPE.PUBORDER_TYPE,
    order_type: ORDER_TYPE_FOR_PUBORDER.HALL_FOOD
  },
  {
    label: '进行中',
    value: 2,
    shop_type: BUSINESS_TYPE.PUBORDER_TYPE,
    order_type: ORDER_TYPE_FOR_PUBORDER.HALL_FOOD
  },
  {
    label: '已完成',
    value: 3,
    shop_type: BUSINESS_TYPE.PUBORDER_TYPE,
    order_type: ORDER_TYPE_FOR_PUBORDER.HALL_FOOD
  },
  {
    label: '已取消',
    value: 4,
    shop_type: BUSINESS_TYPE.PUBORDER_TYPE,
    order_type: ORDER_TYPE_FOR_PUBORDER.HALL_FOOD
  },
  // 公域订单-打包
  {
    label: '待支付',
    value: 1,
    shop_type: BUSINESS_TYPE.PUBORDER_TYPE,
    order_type: ORDER_TYPE_FOR_PUBORDER.PACKING
  },
  {
    label: '进行中',
    value: 2,
    shop_type: BUSINESS_TYPE.PUBORDER_TYPE,
    order_type: ORDER_TYPE_FOR_PUBORDER.PACKING
  },
  {
    label: '已完成',
    value: 3,
    shop_type: BUSINESS_TYPE.PUBORDER_TYPE,
    order_type: ORDER_TYPE_FOR_PUBORDER.PACKING
  },
  {
    label: '已取消',
    value: 4,
    shop_type: BUSINESS_TYPE.PUBORDER_TYPE,
    order_type: ORDER_TYPE_FOR_PUBORDER.PACKING
  },
  // 公域订单-到店消费
  {
    label: '待支付',
    value: 1,
    shop_type: BUSINESS_TYPE.PUBORDER_TYPE,
    order_type: ORDER_TYPE_FOR_PUBORDER.STORECONSUMPTION
  },
  {
    label: '进行中',
    value: 2,
    shop_type: BUSINESS_TYPE.PUBORDER_TYPE,
    order_type: ORDER_TYPE_FOR_PUBORDER.STORECONSUMPTION
  },
  {
    label: '已完成',
    value: 3,
    shop_type: BUSINESS_TYPE.PUBORDER_TYPE,
    order_type: ORDER_TYPE_FOR_PUBORDER.STORECONSUMPTION
  },
  {
    label: '已取消',
    value: 4,
    shop_type: BUSINESS_TYPE.PUBORDER_TYPE,
    order_type: ORDER_TYPE_FOR_PUBORDER.STORECONSUMPTION
  },

  // 公域订单-外卖配送
  {
    label: '待支付',
    value: 1,
    shop_type: BUSINESS_TYPE.PUBORDER_TYPE,
    order_type: ORDER_TYPE_FOR_PUBORDER.TAKE_OUE
  },
  {
    label: '进行中',
    value: 2,
    shop_type: BUSINESS_TYPE.PUBORDER_TYPE,
    order_type: ORDER_TYPE_FOR_PUBORDER.TAKE_OUE
  },
  {
    label: '已完成',
    value: 3,
    shop_type: BUSINESS_TYPE.PUBORDER_TYPE,
    order_type: ORDER_TYPE_FOR_PUBORDER.TAKE_OUE
  },
  {
    label: '已取消',
    value: 4,
    shop_type: BUSINESS_TYPE.PUBORDER_TYPE,
    order_type: ORDER_TYPE_FOR_PUBORDER.TAKE_OUE
  },
  // 公域订单-自提
  {
    label: '待支付',
    value: 1,
    shop_type: BUSINESS_TYPE.PUBORDER_TYPE,
    order_type: ORDER_TYPE_FOR_PUBORDER.SELF_DELIVERY
  },
  {
    label: '进行中',
    value: 2,
    shop_type: BUSINESS_TYPE.PUBORDER_TYPE,
    order_type: ORDER_TYPE_FOR_PUBORDER.SELF_DELIVERY
  },
  {
    label: '已完成',
    value: 3,
    shop_type: BUSINESS_TYPE.PUBORDER_TYPE,
    order_type: ORDER_TYPE_FOR_PUBORDER.SELF_DELIVERY
  },
  {
    label: '已取消',
    value: 4,
    shop_type: BUSINESS_TYPE.PUBORDER_TYPE,
    order_type: ORDER_TYPE_FOR_PUBORDER.SELF_DELIVERY
  },
]

// 附加字段
/*
 * 附加字段(二进制表示：10001 表示显示桌台号、订单号<br/>
 * 餐饮订单：桌台号		取餐码 顾客		消费门店		订单号<br/>
 * 商城订单：			自提/期望送达时间	顾客 消费门店		订单号<br/>
 * 预定订单：			入住/使用时间		顾客		消费门店		订单号)
 * */
export const otherFilesOptions = [
  // 商城订单
  {
    label: '自提/期望送达时间',
    sort: 0,
    type: BUSINESS_TYPE.SHOP_TYPE
  },
  {
    label: '顾客',
    sort: 1,
    type: BUSINESS_TYPE.SHOP_TYPE
  },
  {
    label: '消费门店',
    sort: 2,
    type: BUSINESS_TYPE.SHOP_TYPE
  },
  {
    label: '订单号',
    sort: 3,
    type: BUSINESS_TYPE.SHOP_TYPE
  },
  // 预定订单
  {
    label: '入住/使用时间',
    sort: 0,
    type: BUSINESS_TYPE.BOOK_TYPE
  },
  {
    label: '顾客',
    sort: 1,
    type: BUSINESS_TYPE.BOOK_TYPE
  },
  {
    label: '消费门店',
    sort: 2,
    type: BUSINESS_TYPE.BOOK_TYPE
  },
  {
    label: '订单号',
    sort: 3,
    type: BUSINESS_TYPE.BOOK_TYPE
  },
  // 餐饮订单
  {
    label: '桌台号',
    sort: 0,
    type: BUSINESS_TYPE.MEAL_TYPE
  },
  {
    label: '取餐码',
    sort: 1,
    type: BUSINESS_TYPE.MEAL_TYPE
  },
  {
    label: '顾客',
    sort: 2,
    type: BUSINESS_TYPE.MEAL_TYPE
  },
  {
    label: '消费门店',
    sort: 3,
    type: BUSINESS_TYPE.MEAL_TYPE
  },
  {
    label: '订单号',
    sort: 4,
    type: BUSINESS_TYPE.MEAL_TYPE
  },
  {
    label: '预约时间',
    type: BUSINESS_TYPE.RESERVATION_TYPE
  },
  {
    label: '预约资源名称',
    type: BUSINESS_TYPE.RESERVATION_TYPE
  },
  {
    label: '顾客',
    type: BUSINESS_TYPE.RESERVATION_TYPE
  },
  {
    label: '消费门店',
    type: BUSINESS_TYPE.RESERVATION_TYPE
  },
  {
    label: '订单号',
    type: BUSINESS_TYPE.RESERVATION_TYPE
  },
  {
    label: '订单号',
    type: BUSINESS_TYPE.PUBORDER_TYPE
  },
  {
    label: '消费门店',
    type: BUSINESS_TYPE.PUBORDER_TYPE
  },
  {
    label: '顾客',
    type: BUSINESS_TYPE.PUBORDER_TYPE
  },
  {
    label: '取餐码',
    type: BUSINESS_TYPE.PUBORDER_TYPE
  },
  {
    label: '桌码',
    type: BUSINESS_TYPE.PUBORDER_TYPE
  },
  {
    label: '自提时间',
    type: BUSINESS_TYPE.PUBORDER_TYPE
  },
  {
    label: '预约送达时间',
    type: BUSINESS_TYPE.PUBORDER_TYPE
  }
]

// 十进制转二进制，得到额外字段的文字
export const getExtraColumnText = (obj) => {
  const { extraColumn, businessType } = obj
  let trnansExtraColumn = extraColumn.toString(2)
  while (trnansExtraColumn.length < 4) {
    trnansExtraColumn = '0' + trnansExtraColumn
  }
  const num = trnansExtraColumn.toString(2).split('')

  const options = otherFilesOptions.filter((v) => v.type === businessType)
  const texts = []
  num.map((v, i) => {
    if (Number(v) === 1) {
      texts.push(options[i].label)
    }
  })
  return texts
}
